use pnet::datalink;

#[test]
fn test_datalink_channel() {
    let all_interfaces = datalink::interfaces();
    for interface in all_interfaces {
        println!("Interface name: {}", interface.name);
        println!("Interface description: {}", interface.description);
        println!("Interface MTU: {}", interface.mac.unwrap());
        println!("Interface hardware address: {:?}", interface.mac.unwrap());
        println!("Interface IP addresses:{}", interface.ips.iter().nth(0).unwrap());
        for ip_address in interface.ips {
            println!("{}", ip_address);
        }
    }
}


#[test]
fn test_get_default_interface() {
    let all_interfaces = datalink::interfaces();
    // Search for the default interface - the one that is
    // up, not loopback and has an IP.
    let default_interface = all_interfaces
        .iter()
        .find(|e| e.is_up() && !e.is_loopback() && !e.ips.is_empty());

    match default_interface {
        Some(interface) => println!("Found default interface with [{}].", interface.name),
        None => println!("Error while finding the default interface."),
    }
}

#[test]
fn test_create_channel() {
    let _all_interfaces = datalink::interfaces();
    // Search for the default interface - the one that is
    // up, not loopback and has an IP.
    // let default_interface = all_interfaces
    //    .iter()
    //    .find(|e| e.is_up() &&!e.is_loopback() &&!e.ips.is_empty());

    // match default_interface {
    //     Some(interface) => {
    //     }
    // }
}